$(function () {
    $(".login_phone").change(function () {
        check_input(/^1(3|4|5|7|8)\d{9}$/,$(this).val(),$(this));
    })
    $(".login_pwd").change(function () {
        check_input(/^[a-zA-Z\d_]{8,}$/,$(this).val(),$(this))
    })

    $(".login_click").click(function () {
        if(/^1(3|4|5|7|8)\d{9}$/.test($(".login_phone").val()) && /^[a-zA-Z\d_]{8,}$/.test($(".login_pwd").val())){
            $.ajax({
                url:"../../../front/php/login.php",
                data: {phone:$(".login_phone").val(),pwd:$(".login_pwd").val()},
                dataType:"json",
                type:"GET",
                success:function (d) {
                    if(d.code == "S"){
                        window.location.href = "../index.html"
                    }
                }
            })
        }
    })
    function check_input(reg,val,that) {
        if(reg.test(val)){
            that.parent().parent().prop("class","weui-cell weui-cell_success").find("i").prop("class","weui-icon-success")
        }else{
            that.parent().parent().prop("class","weui-cell weui-cell_warn").find("i").prop("class","weui-icon-warn")
        };
    }
})